package com.cn.serverline.lineicp.productionLine.controller;

import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import javax.annotation.Resource;

import com.cn.serverline.lineicp.productionLine.param.ProductionProcessesAddParam;
import com.cn.serverline.lineicp.productionLine.param.ProductionProcessesEditParam;
import com.cn.serverline.lineicp.productionLine.param.ProductionProcessesIdParam;
import com.cn.serverline.lineicp.productionLine.param.ProductionProcessesPageParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import com.cn.serverline.lineicp.productionLine.entity.ProductionProcesses;
import com.cn.serverline.lineicp.productionLine.service.IProductionProcessesService;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;


/**
 * 工序 接口
 *
 * @author Gmr
 * @since 2024-07-30
 */
@RestController
@Api(tags = "工序")
@ApiResource(name = "工序的接口")
public class ProductionProcessesController {

    @Resource(name = "ProductionProcessesServiceImpl")
    private IProductionProcessesService iProductionProcessesService;

    /**
     * 添加工序
     */
    @ApiOperation(value = "添加工序")
    @PostResource(name = "添加工序", path = "/productionLine/productionProcesses/add")
    public ResponseData<?> add(@RequestBody @Validated ProductionProcessesAddParam processesAddParam){
        iProductionProcessesService.add(processesAddParam);
        return new SuccessResponseData<>();
    }

    /**
     * 删除工序
     */
    @ApiOperation(value = "删除工序")
    @PostResource(name = "删除工序", path = "/productionLine/productionProcesses/delete")
    public ResponseData<?> delete(@RequestBody @Validated ProductionProcessesIdParam productionProcesses){
        iProductionProcessesService.del(productionProcesses);
        return new SuccessResponseData<>();
    }

    /**
     * 编辑工序
     */
    @ApiOperation(value = "编辑工序")
    @PostResource(name = "编辑工序", path = "/productionLine/productionProcesses/edit")
    public ResponseData<?> edit(@RequestBody @Validated ProductionProcessesEditParam productionProcesses) {
        iProductionProcessesService.edit(productionProcesses);
        return new SuccessResponseData<>();
    }

    /**
     * 分页查询-工序列表
     */
    @ApiOperation(value = "分页查询-工序列表")
    @GetResource(name = "分页查询-工序列表", path = "/productionLine/productionProcesses/page")
    public ResponseData<PageResult<ProductionProcesses>> page(@Validated ProductionProcessesPageParam productionProcesses) {
        return new SuccessResponseData<>(iProductionProcessesService.findPage(productionProcesses));
    }

}
